<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values"></cfg-form>
</template>

<script>
const ref = "createView";
export default {
  name: ref,
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref,
      onlyRead: false,
      loading: false,
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
  },
  watch: {},
  computed: {
    attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 3,
        columns: [
          {
            key: "planBatchNo",
            title: "计划批次号",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "text" },
          },
          {
            key: "productId",
            title: "产物规格",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "select", options: this.anc.productOptions },
          },
          // {
          //   key: "planType",
          //   title: "计划类型",
          //   minWidth: 200,
          //   align: "center",
          //   show: true,
          //   config: { type: "text" },
          // },
          {
            key: "status",
            title: "状态",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "text" },
          },

          {
            key: "planStartTime",
            title: "计划开始时间",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "datetime" },
          },
          {
            key: "planEndTime",
            title: "计划结束时间",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "datetime" },
          },
          {
            key: "startTime",
            title: "开始时间",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "datetime" },
          },
          {
            key: "endTime",
            title: "结束时间",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "datetime" },
          },
          {
            key: "totalCapacity",
            title: "计划产量",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "number" },
          },
          {
            key: "usedCapacity",
            title: "已产量",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "number" },
          },
          {
            key: "restCapacity",
            title: "剩余未产",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "number" },
          },
          {
            key: "remark",
            title: "备注",
            minWidth: 200,
            align: "center",
            show: true,
            config: { type: "textarea" },
          },
        ],
        rules: {
          planBatchNo: [
            { required: true, message: "请输入计划批次号", trigger: "blur" },
          ],
          productId: [
            {
              required: true,
              message: "请输入产物规格",
              trigger: "change",
              type: "number",
            },
          ],
          planStartTime: [
            {
              required: true,
              message: "请输入计划开始时间",
              trigger: "change",
            },
          ],
          planEndTime: [
            {
              required: true,
              message: "请输入计划结束时间",
              trigger: "change",
            },
          ],
        },
      };
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);

      // this.jobClassObject = this.$modelObject.create(
      //   `${typeClassName["job"].modelType}`
      // );

      // this.anc.setOptionsByHier(
      //   "job",
      //   this.jobClassObject,
      //   "jobOptions",
      //   {
      //     label: "sf_name",
      //     value: "sf_code",
      //   },
      //   "createView"
      // );
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if (fn) {
          return fn(valid);
        } else {
          return valid;
        }
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped></style>
